import request from '@/utils/request';
import { ChannelQuery, ChannelVO, ChannelForm } from './types';

// 查询通道列表
export function getChannelList(query: ChannelQuery) {
    return request({
        url: '/vending/channel/list',
        method: 'get',
        params: query
    });
}

// 获取通道详细信息
export function getChannelDetail(id: number) {
    return request({
        url: `/vending/channel/${id}`,
        method: 'get'
    });
}

// 新增通道
export function createChannel(data: ChannelForm) {
    return request({
        url: '/vending/channel',
        method: 'post',
        data
    });
}

// 修改通道
export function updateChannel(data: ChannelForm) {
    return request({
        url: '/vending/channel',
        method: 'put',
        data
    });
}

// 删除通道
export function deleteChannel(id: number) {
    return request({
        url: `/vending/channel/${id}`,
        method: 'delete'
    });
}

// 批量删除通道
export function deleteChannelBatch(ids: number[]) {
    return request({
        url: `/vending/channel/batch/${ids.join(',')}`,
        method: 'delete'
    });
}

// 根据设备ID查询通道列表
export function getChannelListByDeviceId(deviceId: number) {
    return request({
        url: `/vending/channel/device/${deviceId}`,
        method: 'get'
    });
} 